import redis.clients.jedis.Jedis;
import redis.clients.jedis.JedisPool;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 九转苍翎
 * Date: 2025/11/2
 * Time: 18:55
 */
public class RedisDemo {
    public static void main(String[] args) {
        try(JedisPool jedisPool = new JedisPool("tcp://127.0.0.1:6379");
        Jedis jedis = jedisPool.getResource()) {
            System.out.println(jedis.ping());
            test1(jedis);
            test2(jedis);
        }
    }

    public static void test1(Jedis jedis) {
        jedis.flushAll();
        jedis.set("key1", "value1");
        jedis.set("key2", "value2");
        jedis.set("key3", "value3");
        String string = jedis.get("key1");
        System.out.println("value:" + string);
    }

    public static void test2(Jedis jedis) {
        boolean flg = jedis.exists("key1");
        System.out.println("result:" + flg);
    }
}